{extend name="public/base" /}

{block name="pjax_container"}
<?php
    $titleTypeName = '事件视图';
?>
<style>
    /* input{
        margin-right:10px;
    } */
    .layui-layer-content{
        padding: 15px;
    }
    select{
     
        height:30px;
        margin-right:10px;
    }
     .input-group{
       overflow:hidden;
     }
    .input-group p{
       padding-top: 10px;
       font-size: 16px;
       margin-right: 10px;
      white-space: nowrap;
    }
    .input-group label{
        width: 335px;
        float:left;
        justify-content: flex-start;
        display: flex;
        align-items: center; 
        margin-left:5px;
    }

  
   
   .pagination{
       float: right;
   }

   button{
        padding: 5px;
   }
   .select2{
       width: 75px;
   }
   
.content-header>.breadcrumb>li{
    color: #999;
}
.content-header>.breadcrumb>.active{
    color: #666;
}
.content-header{
    height: 51px;
 
}
.btn-primary{
    background-color: #1890FF;
    color: #fff;
    border: none;
    margin-left: 15px;
    padding: 5px 10px; 
    line-height: 24px;
}
.box-primary{
  border-top-color: #ecf0f5 !important;
  border-top-width: 16px;
  
}
.btn-primary:hover{
    background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .9;
}
.delete-one{
    background-color: ff4141 !important;
    margin-left: 15px;
    border-radius: 6px;
}
.sreachs{
    background-color: #1890FF;
    color: #fff;
    border: none;
    margin-left: 15px;
    margin-bottom: 5px;
    padding: 7px 15px; 
    height: 34px !important;
    
}
.active>span{
    background-color: #1890FF !important;
    border-color: #1890FF !important;
}
tr>th,td{
    text-align: center;
}
.select2{
    width: 260px !important;
}
    .table-body {
        width: 554px;
        height: 470px;
        border-radius: 6px;
        background-color: #eee;
    }
    .table-left {
        margin-right: 2%;
        width: 49%;
        height: 100%;
        float: left;
        border: 1px solid #eee;
        background-color: #fff;
    }
    .modal-left {
        height: 100%;
    }
    .table-right {
        width: 49%;
        height: 100%;
        border: 1px solid #eee;
        float: left;
        background-color: #fff;
    }
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>核查查看</li>
        <li class="active">{$titleTypeName}</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-tools" style="margin:5px;">
                    <form id="form1" action="{:search_url(['theme', 'event_id', 'department_id', 'user_id', 'prize_buckle_time', 'status', 'record_user_id', 'first_check_user_id', 'last_check_user_id', 'integral_a_start', 'integral_a_end', 'integral_b_start','integral_b_end','is_lottery_ticket'])}" method="GET" pjax-search="">
                        <div class="input-group input-group-sm" style="display: flex; align-items: center; flex-wrap: wrap;">
                            <input type="hidden" name="page" value="1" />
                            <label>
                                <p>主　　题:</p>
                                <input class="form-control" name="theme" value="{:input('get.theme','')}" placeholder="请输入主题名称" autocomplete="off" style="width:260px">
                            </label>
                            <label>
                                <p>事　　件:</p>
                                <div class="xyqk_input">
                                    <input class="form-control event_id_name" name="event_id_name" value="{:input('get.event_id_name','')}" placeholder="选择事件" autocomplete="off" style="width:260px">
                                    <input type="hidden" class="event_id" value="{:input('get.event_id','')}" name="event_id">
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>
                                <!-- <select class="select2" name="event_id">
                                    <option value="0">请选择事件</option>
                                    {foreach name="$event_list" item="vo"}
                                        <option value="{$vo['id']}" {if condition="input('event_id') == $vo['id']" }selected{/if}> {$vo['name']} / {$cate_list[$vo['cate_id']]['name']|default='' } </option> 
                                    {/foreach} 
                                </select> -->
                            </label>
                            <label>
                                <p>组织机构:</p>
                                <div class="xyqk_input">
                                    <input class="form-control department_id_name" name="department_id_name" value="{:input('get.department_id_name','')}" placeholder="组织机构" autocomplete="off" style="width:260px">
                                    <input type="hidden" class="department_id" value="{:input('get.department_id','')}" name="department_id">
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>
                                <!-- <select class="select2" name="department_id" style="width:300px;">
                                    <option value="0">组织机构</option>
                                    {foreach name="$com_department" item="vo"}
                                    <option value="{$vo['id']}" {if condition="input('department_id') == $vo['id']" }selected{/if}> {for start="0" end="$vo['num']" } |------ {/for} {$vo['name']} </option> 
                                    {/foreach}
                                </select> -->
                            </label>
                            <label>
                                <p>奖扣对象:</p>
                                <div class="xyqk_input">
                                    <input class="form-control user_id_name" name="user_id_name" value="{:input('get.user_id_name','')}" placeholder="奖扣对象" autocomplete="off" style="width:260px">
                                    <input type="hidden" class="user_id" value="{:input('get.user_id','')}" name="user_id">
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>
                                <!-- <select class="select2" name="user_id" style="width:150px;">
                                    <option value="0">请选择</option>
                                    {foreach name="$cy_ids" item="vo"}
                                        <option value="{$vo}" {if condition="input('user_id') == $vo" }selected{/if}>{$user_list[$vo]|default=''} </option> 
                                    {/foreach}
                                </select> -->
                            </label>
                            <label>
                                    <p>奖扣时间:</p>
                                    <input class="form-control lay_date" name="prize_buckle_time" value="{$prize_buckle_time}" placeholder="奖扣时间" AUTOCOMPLETE="off"  style="width:256px">
                            </label>

                            <label>
                                <p>状　　态:</p>
                                <select class="select2" name="status">
                                    <option value="-1"{if condition="input('status',-1) == -1" }selected{/if}>全部</option>
                                    <option value="0" {if condition="input('status',-1) == 0" }selected{/if}>审核通过 </option>
                                    <option value="1" {if condition="input('status',-1) == 1" }selected{/if}>已作废 </option>
                                </select>
                            </label>
                            <label>
                                <p>记　录人:</p>
                                <div class="xyqk_input">
                                    <input class="form-control record_user_name" name="record_user_name" value="{:input('get.record_user_name','')}" placeholder="记录人" autocomplete="off" style="width:260px">
                                    <input type="hidden" class="record_user_id"  value="{:input('get.record_user_id','')}" name="record_user_id">
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>

                            </label>

                            <label>
                                    <p>初　审人:</p>
                                    <div class="xyqk_input">
                                        <input class="form-control first_check_user_name" name="first_check_user_name" value="{:input('get.first_check_user_name','')}" placeholder="初审人" autocomplete="off" style="width:260px">
                                        <input type="hidden" class="first_check_user_id" value="{:input('get.first_check_user_id','')}" name="first_check_user_id">
                                        <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                    </div>

                            </label>
                            <label>
                                    <p>终　审人:</p>
                                    <div class="xyqk_input">
                                        <input class="form-control last_check_user_name" name="last_check_user_name" value="{:input('get.last_check_user_name','')}" placeholder="终审人" autocomplete="off" style="width:260px">
                                        <input type="hidden" class="last_check_user_id" value="{:input('get.last_check_user_id','')}" name="last_check_user_id">
                                        <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                    </div>

                            </label>

                            <label>
                                    <p>A 分区间:</p>
                                    <input class="form-control" name="integral_a_start" value="{:input('get.integral_a_start')}" placeholder="起始区间"
                                        AUTOCOMPLETE="off" >　-　　
                                    <input class="form-control" name="integral_a_end" value="{:input('get.integral_a_end')}" placeholder="终止区间"
                                        AUTOCOMPLETE="off" >
                            </label>

                            <label>
                                    <p>B 分区间: </p>
                                    <input class="form-control" name="integral_b_start" value="{:input('get.integral_b_start')}" placeholder="起始区间"
                                        AUTOCOMPLETE="off" style="width:105px">　-　　
                                    <input class="form-control" name="integral_b_end" value="{:input('get.integral_b_end')}" placeholder="终止区间"
                                        AUTOCOMPLETE="off" style="width:105px">
                            </label>

                            <label>
                                    <p>奖票状态:</p>
                                    <select class="select2" name="is_lottery_ticket">
                                        <option value="-1">全部</option>
                                        <option value="0" {if condition="input('is_lottery_ticket', -1) == 0" }selected{/if}>不是 </option> 
                                        <option value="1" {if condition="input('is_lottery_ticket', -1) == 1" }selected{/if}>是 </option> 
                                    </select>
                            </label>
                            <button type="submit" class="btn btn-default sreachs">
                                    <i class="fa fa-search"></i> 查询
                            </button>
                            <div class="input-group-btn" >
                                
                            </div>
                        </div>
                    </form>
                </div>

                <div class="box-header with-border">
                    <div class="pull-left">
                        <a href="javascript:xls_explode();" class="btn btn-sm btn-primary"><i class="fa fa-cloud-upload"></i> 导出</a>


                    </div>
                    <div class="pull-right">
                        {:authAction(CONTROLLER_NAME.'/ticket_change','ticket_change')}
                        {:authAction(CONTROLLER_NAME.'/integral_cancellation','integral_cancellation')}
                        {:authAction(CONTROLLER_NAME.'/integral_recover','integral_recover')}
                    </div>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>奖扣对象</th>
                            <th>奖扣时间</th>
                            <th>主题名称</th>
                            <th>事件名称</th>
                            <th>A分</th>
                            <th>B分</th>
                            <th>奖票</th>
                            <th>记录人</th>
                            <th>初审人</th>
                            <th>终审人</th>
                            <th>状态</th>
                        </tr>
                        {volist name="$list" id="v"}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$v.id}" class="minimal checkbox"></td>
                            <!--<td>{$user_list[$v['user_id']]|default=''}</td>-->
                            <td><a href="{:url('index', ['user_id'=>$v['user_id']])}">{$user_list[$v['user_id']]|default=''}</a></td>
                            <td>{:date('Y-m-d', $v['prize_buckle_time'])}</td>
                            <td><a href="{:url('integral/event_info', ['id'=>$v['pb_id']])}">{$v['theme']}</a></td>
                            <td>{$v['name']}</td>
                            <td {if condition="$v.integral_a <0"}style="color:red;"{/if}>{$v['integral_a']}</td>
                            <td {if condition="$v.integral_b <0"}style="color:red;"{/if}>{$v['integral_b']}</td>
                            <td>{$is_lottery_ticket[$v['is_lottery_ticket']]}</td>
                            <td>{$user_list[$v['record_user_id']]|default=''}</td>
                            <td>{$user_list[$v['first_check_user_id']]|default=''}</td>
                            <td>{$user_list[$v['last_check_user_id']]|default=''}</td>
                            <td>{if condition="$v.is_cancellation ==0"}审核通过{else:}作废{/if}</td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(function(){

        $(".select2").select2({language:"zh-CN"});

        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });

    layui.use(['layer', 'laydate', 'upload'], function(){
        var laydate = layui.laydate;
        var layer = layui.layer;
        var upload = layui.upload;
        var layer_index = '';//加载层
        var nowtime = "{:date('Y-01-01 H:i:s',time())}";
        laydate.render({
            range:true,
            elem: '.lay_date',
            // min: nowtime
        });
        upload.render({
            elem: '#import'
            ,url: "{:url('Review/review_import')}",
            accept:"file",
            exts:'xls|xlsx',
            size:'8192', // 8M大小
            choose:function(obj){
                layer_index = layer.load(2);
            },
            done: function(res){
                layer.close(layer_index);
                if(res.err == 1){
                    layer.msg(res.msg, {icon:2});
                }else{
                    layer.msg(res.msg, {icon:1}, function(){
                        location.reload();
                    });
                }
            },
            error: function(){
                layer.close(layer_index);
            }
        });
    });

    function xls_explode() {
        window.location.href = "{:url('Review/index')}?" + $('#form1').serialize()+'&export=1';
        return false;
    }
</script>


<!-- 弹框样式引入 -->
<link rel="stylesheet" href="__STATIC__/global/an_tree_css/an_tree_css.css">

<!-- Modal 弹出层重写 事件选择  -->
<div class="modal fade" id="myModal_things" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="width: 585px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel_things">事件选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                        style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body">
                        <div class="table-left">
                            <div class="an_tree">

                            </div>
                        </div>
                        <div class="table-right">
                            <div class="an_tree_list">
                                <!-- <div class="an_list_title">

                                </div> -->
                                <div class="an_list_con">
                                    <!-- <div class="an_list_item">
                                        <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                                        <div class="item_info">
                                            <span class="name">专审事件锁定测试</span>
                                            <span>工作类事件 / 日常工作类事件</span>
                                        </div>
                                    </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit">确认</button>
            </div>
        </div>
    </div>
    <!-- <div class="content_tips">
        <p>事件分类：<span>工作类事件/ 日常工作类事件</span></p>
        <p>分值范围：<span>A分:0 ~ 0 B分:100 ~ 200 产值:0 ~ 0</span></p>
        <p>事件属性：<span>专审事件 计件事件</span></p>
        <p><p>备注信息：</p><p><span>暂无备注信息</span></p></p>
    </div> -->
</div>
<!-- 提示操作 事件选择  -->
<script>
    $("#myModal_things").on("mouseenter", ".an_list_item", function () {
        var i = $("#myModal_things .an_list_con .an_list_item").index(this);
        $("#myModal_things .content_tips").eq(i).show();
    });
    $("#myModal_things").on("mouseleave", ".an_list_item", function () {
        $("#myModal_things .content_tips").hide();
    });
    $('#myModal_things').mousemove(function (e) {
        var xx = e.originalEvent.x;//e.originalEvent.x; || e.originalEvent.layerX || 0
        var yy = e.originalEvent.y;//e.originalEvent.y; || e.originalEvent.layerY || 0;
        $("#myModal_things .content_tips").css("left", xx);
        $("#myModal_things .content_tips").css("top", yy);
        // console.log(xx);
        // console.log(yy);
    });
</script>
<!-- 单选弹窗操作 事件选择  -->
<script>
    var now_item_name;//名字输入框
    var now_item_id;//id输入框
    //确认按钮   事件选择完成后要添加初审人终审人下拉框
    $('#myModal_things .popups_submit').click(function (e) {
        $('#myModal_things').modal('hide');
        var checked = $(".an_tree_list").find(".list_item_check");
        now_item_name.val(checked.attr("data_name"));
        now_item_id.val(checked.attr("data_id"));

    });
    //当弹窗关闭时执行重置弹窗
    $('#myModal_things').on('hidden.bs.modal', function () {
        // 执行一些动作...重置弹窗
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $("#myModal_things input[name='search_user_name']").val("");
    });
    // 事件选择
    $('body').on('focus', '.event_id_name', function () {
        $('#myModal_things').modal('show');
        now_item_name = $(this);
        now_item_id = $(this).siblings(".event_id");//节点
    });
</script>
<!-- 树结构js操作 事件选择  -->
<script>
    $("#myModal_things .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_things").on("click", ".an_tree_txt,.search_btn", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        // var department_name = $(this).html();
        var user_name = $("#myModal_things input[name='search_user_name']").val();
        // console.log(user_name);
        $.ajax({
            type: 'get',
            url: "{:url('base/base_event_child')}",
            data: {'id': department_id, 'search_name': user_name },
            dataType: "json",
            success: function (data) {
                things_data = data;
                // console.log(data);
                // return false;
                var content = '';
                var content_tips = '';
                $.each(data, function (index, value) {
                    if (value.is_piece) {
                        var is_piece = '<p>事件属性：<span>计件事件</span></p>';
                    } else {
                        var is_piece = '';
                    }
                    if (value.desc == "") {
                        var desc = '<span>暂无备注信息</span>'
                    } else {
                        var desc = '<span>' + value.desc + '</span>'
                    }
                    content += '<div class="an_list_item" data_id="' + value.id + '" data_name="' + value.name + '" is_piece="' + value.is_piece + '" integral_a_start="'+value.integral_a_start+'" integral_a_end="'+value.integral_a_end+'" integral_b_start="'+value.integral_b_start+'" integral_b_end="'+value.integral_b_end+'"> <div class="item_box item_box_check"><i class="fa fa-check"></i></div> <div class="item_info"> <span class="name">' + value.name + '</span> <span>' + value.show_cate_name + '</span> </div> </div>';
                    content_tips += '<div class="content_tips"> <p>事件分类：<span>' + value.show_cate_name +'</span></p> <p>分值范围：<span>A分:' + value.integral_a_start + ' ~ ' + value.integral_a_end + ' B分:' + value.integral_b_start + ' ~ ' + value.integral_b_end + '</span></p>' + is_piece + '<p><p>备注信息：</p><p>' + desc + '</p></p> </div>'

                });
                $('.an_list_con').html("");
                $('.an_list_con').append(content);
                $("#myModal_things .content_tips").remove();
                $("#myModal_things").append(content_tips);
            }
        })
    });
    $("#myModal_things .an_tree_list").on("click", ".an_list_item", function () {
        $(this).siblings().removeClass("list_item_check");
        $(this).toggleClass("list_item_check")
    })
</script>
<!-- 递归填充目录 事件选择  -->
<script>
    var eventList;
    $.ajax({
        type: 'get',
        url: "{:url('base/base_event_cate')}",
        dataType:"json",
        async: false,
        success: function (data) {
            eventList = JSON.parse(data);
        }
    })
    var an_tree = ergodic(eventList);
    $("#myModal_things .an_tree").append(an_tree);

    function ergodic(data) {
        var content = '';
        // console.log(data);
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>


<!-- Modal 弹出层重写 部门单选  id="myModal_single"-->
<div class="modal fade" id="myModal_department_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="width:515px;height: 635px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">部门选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left" style="width:485px;">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body" style="width: 485px">
                        <div class="table-left" style="width: 100%;">
                            <div class="an_tree search_hide">

                            </div>
                            <div class="search_show" style="display: flex;  flex-direction: column;padding: 20px 10px;">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<style>
.a{
    flex-direction: row;
}
</style>
</div>
<!-- 部门弹窗操作 部门单选   -->
<script>
    var now_item_name;
    var now_item_id;
    $(".department_id_name").focus(function () {
        $('#myModal_department_single').modal('show');
        // double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $(".department_id");//节点
        // first_id = $("input[name='first_check_user_id']").val();//id值
        // user_type = 2;
    });

</script>
<!-- 树结构js操作 部门单选  -->
<script>
    $("#myModal_department_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_department_single").on("click", ".an_tree_txt", function () {
        $('#myModal_department_single').modal('hide');
        now_item_name.val($(this).html());
        now_item_id.val($(this).attr("data_id"));
    });
    $("#myModal_department_single").on("click", ".search_btn", function () {
        var item = $("#myModal_department_single .an_tree_txt");
        var search_name = $("#myModal_department_single input[name='search_user_name']").val();
        $("#myModal_department_single .search_show").html("");
        if(search_name == ""){
            $("#myModal_department_single .search_hide").show();
            $("#myModal_department_single .search_show").removeClass("an_tree");
        }else{
            $("#myModal_department_single .search_hide").hide();
            $("#myModal_department_single .search_show").show();
            var content = "";
            for (let i = 0; i < item.length; i++) {
                var name = item.eq(i).html();
                if (name.indexOf(search_name) != -1) {
                    content += item.eq(i).prop("outerHTML");
                }
                console.log(name);
            }
            $("#myModal_department_single .search_show").append(content)
        }
        
    });
</script>
<!-- 递归填充目录 部门单选  -->
<script>
    var department = "";
    $.ajax({
        type: 'get',
        url: "{:url('base/base_department_page')}",
        dataType:"json",
        async: false,
        success: function (data) {
            // eventList = JSON.parse(data);
            department = data;
        }
    })
    var an_tree = ergodic(department)
    $("#myModal_department_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>

<!-- Modal 弹出层重写 人员单选  -->
<div class="modal fade" id="myModal_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="width: 585px">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" >人员选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body">
                        <div class="table-left">
                            <div class="an_tree">

                            </div>
                        </div>
                        <div class="table-right">
                            <div class="an_tree_list">
                                <div class="an_list_title">

                                </div>
                                <div class="an_list_con">
                                    <!-- <div class="an_list_item">
                                        <div class="item_info">
                                            <span class="name">aaa</span>/
                                            <span>88</span>/
                                            <span>部门</span>
                                        </div>
                                        <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                                    </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit">确认</button>
            </div>
        </div>
    </div>

</div>
<!-- 单选弹窗操作  -->
<script>

    var now_item_name;//名字输入框
    var now_item_id;//id输入框
    //确认按钮
    $('#myModal_single .popups_submit').click(function (e) {
        $('#myModal_single').modal('hide');
        var checked = $(".an_tree_list").find(".list_item_check");
        now_item_name.val(checked.attr("user_name"));
        now_item_id.val(checked.attr("user_id"));
        now_item_name.attr("limits_b",checked.attr("limits_b"))
    });
    //当弹窗关闭时执行重置弹窗
    $('#myModal_single').on('hidden.bs.modal', function () {
        // 执行一些动作...重置弹窗
        $(".an_tree_list .an_list_title").html("");
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $("#myModal_single input[name='search_user_name']").val("");
    });
    // 奖扣对象
    $("input[name='user_id_name']").focus(function () {
        $('#myModal_single').modal('show');
        now_item_name = $(this);
        now_item_id = $("input[name='user_id']");//节点
    });
    // 记录人
    $("input[name='record_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        now_item_name = $(this);
        now_item_id = $("input[name='record_user_id']");//节点
    });
    // 初审人
    $("input[name='first_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        now_item_name = $(this);//节点
        now_item_id = $("input[name='first_check_user_id']");//节点
    });
    // 终审人
    $("input[name='last_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        now_item_name = $(this);//节点
        now_item_id = $("input[name='last_check_user_id']");//节点
    });
</script>
<!-- 树结构js操作 单选  -->
<script>
    $("#myModal_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_single").on("click", ".an_tree_txt,.search_btn", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        var department_name = $(this).html();
        var user_name = $("#myModal_single input[name='search_user_name']").val();
        // console.log(user_name);
        $.ajax({
            type: 'get',
            url: "{:url('base/base_department_per')}",
            data: {'department_id' : department_id,'user_name' : user_name},
            dataType:"json",
            success: function (data) {
                // var json = JSON.parse(data);
                // console.log(data);
                var content = '';
                $.each(data, function (index, value) {
                    if(value.limits==undefined){
                         var limits=0;
                    }else{
                        var limits=value.limits.b;
                    }
                    content += '<div class="an_list_item" user_name="'+value.name+'" user_id="'+value.id+'" limits_b="'+limits+'"><div class="item_info"><span class="name">' + value.name + '</span>/<span>' + value.job_number + '</span>/<span>' + value.department_name + '</span></div><div class="item_box "><i class="fa fa-check"></i></div></div>'
                });
                $('.an_list_con').html("");
                $('.an_list_con').append(content);
                $('.an_list_title').html(department_name + data.length + '人');
            }
        })
    });
    $("#myModal_single .an_tree_list").on("click", ".an_list_item", function () {
        $(this).siblings().removeClass("list_item_check");
        $(this).toggleClass("list_item_check")
    })
</script>
<!-- 递归填充目录 单选  -->
<script>
    var an_tree = ergodic(department);
    $("#myModal_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>
<script>
    $('.ticket_change').on('click',function () {
        var url = $(this).attr('data-url');
        var url2 = '?'+$('#form1').serialize();
        if (!confirm("确定转换？")){return false}
        //获取选中人数据
        var _table = $('.checked');
        if(_table.length == 0){
            $.amaran({'message':'请选择用户'});
            return false;
        }
        var ids = [];
        var id;
        _table.each(function(){
            id = $(this).find("input[type='checkbox']").iCheck("check").val();
            if(id != 'on'){
                ids[ids.length] = id;
            }
        });
        $.ajax({
            url:url,
            data:{ids:ids},
            type:'post',
            success:function (data) {
                $.amaran({'message':data.msg});
                if(data.code == 0){
                    $.pjax({'url': "{:url('index')}"+url2, container: '#pjax-container', fragment:'#pjax-container'});
                }
            }
        })
    })
    $('.integral_cancellation').on('click',function () {
        var url = $(this).attr('data-url');
        var url2 = '?'+$('#form1').serialize();
        if (!confirm("确定作废？")){return false}
        //获取选中人数据
        var _table = $('.checked');
        if(_table.length == 0){
            $.amaran({'message':'请选择用户'});
            return false;
        }
        var ids = [];
        var id;
        _table.each(function(){
            id = $(this).find("input[type='checkbox']").iCheck("check").val();
            if(id != 'on'){
                ids[ids.length] = id;
            }
        });
        $.ajax({
            url:url,
            data:{ids:ids},
            type:'post',
            success:function (data) {
                $.amaran({'message':data.msg});
                if(data.code == 0){
                    $.pjax({'url': "{:url('index')}"+url2, container: '#pjax-container', fragment:'#pjax-container'});
                }
            }
        })
    })
    $('.integral_recover').on('click',function () {
        var url = $(this).attr('data-url');
        var url2 = '?'+$('#form1').serialize();
        if (!confirm("确定恢复？")){return false}
        //获取选中人数据
        var _table = $('.checked');
        if(_table.length == 0){
            $.amaran({'message':'请选择用户'});
            return false;
        }
        var ids = [];
        var id;
        _table.each(function(){
            id = $(this).find("input[type='checkbox']").iCheck("check").val();
            if(id != 'on'){
                ids[ids.length] = id;
            }
        });
        $.ajax({
            url:url,
            data:{ids:ids},
            type:'post',
            success:function (data) {
                $.amaran({'message':data.msg});
                if(data.code == 0){
                    $.pjax({'url': "{:url('index')}"+url2, container: '#pjax-container', fragment:'#pjax-container'});
                }
            }
        })
    })
</script>
{/block}
